<?php
class AppException extends Exception
{
	public function __construct( $errorCode , $errorMessage = '' )
	{
	$errorConfig = & Common::getConfig( 'ErrorConfig' );
        $errorConfig[ $errorCode ]['error'] = isset( $errorConfig[ $errorCode ]['error'] ) ? str_replace( '{errorMessage}', $errorMessage , $errorConfig[ $errorCode ]['error'] ) : $errorMessage;
        $errorConfig[ $errorCode ]['message'] = isset( $errorConfig[ $errorCode ]['message'] ) ? str_replace( '{errorMessage}', $errorMessage , $errorConfig[ $errorCode ]['message'] ) : $errorMessage;
        $errorMessage = json_encode( $errorConfig[ $errorCode ] );
        
	parent::__construct( $errorMessage , $errorCode );
        $errorMsg = $this->getMessage();
        return $errorMsg;
	}      
}
       
//        try
//       { 
//         if(filter_var($email, FILTER_VALIDATE_EMAIL) === FALSE)
//          {
//          throw new AppException($email);
//          }
//        }
//
//        catch (AppException $e)
//         { 
//          echo $e->getMessage();
//         }